﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 晨曦超市管理系统.客户信息
{
    public partial class add : Form
    {
        public add()
        {
            InitializeComponent();
        }

        private void add_Load(object sender, EventArgs e)
        {
        }
        public void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text=="")
                {
                    MessageBox.Show("供货商号不能为空");
                }
                if (textBox2.Text == "")
                {
                    MessageBox.Show("供货名称不能为空");
                }
                if (textBox3.Text == "")
                {
                    MessageBox.Show("联系人不能为空");
                }
                if (textBox4.Text == "")
                {
                    MessageBox.Show("联系电话不能为空");
                }
                if (textBox5.Text == "")
                {
                    MessageBox.Show("开户银行不能为空");
                }
                if (textBox6.Text == "")
                {
                    MessageBox.Show("银行卡号不能为空");
                }
                if (textBox7.Text == "")
                {
                    MessageBox.Show("联系地址不能为空");
                }
                string SupplierID = textBox1.Text.Trim();
                string Name = textBox2.Text.Trim();
                string Linkman = textBox3.Text.Trim();
                string Phone = textBox4.Text.Trim();
                string ContactAddress = textBox5.Text.Trim();
                string CardDoorBank = textBox6.Text.Trim();
                string BankAccount = textBox7.Text.Trim();
                string Remark = textBox8.Text.Trim();
                string sqlstr = string.Format(@"insert into ProfferBill(SupplierID,Name,Linkman,Phone,ContactAddress,CardDoorBank,BankAccount,Remark)
                                         values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')", SupplierID, Name, Linkman, Phone, ContactAddress, CardDoorBank, BankAccount, Remark);
                bool Zen = DBHelper.QEX(sqlstr);
                if (Zen)
                {
                    MessageBox.Show("添加成功");
                    textBox1.Text="";
                    textBox2.Text="";
                    textBox3.Text="";
                    textBox4.Text="";
                    textBox5.Text="";
                    textBox6.Text="";
                    textBox7.Text="";
                    textBox8.Text = "";
                }
                else
                {
                    MessageBox.Show("添加不成功");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("登录异常请尽快联系管理员原因"+ex.Message);
            }
        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
